OPC Studio User's Guide and Reference
Installed Examples - Web - BrowseServersWeb

Browses the available OPC "Classic" servers (ASP.NET Web application).

The default page code-behind:

// $Header: $
// Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved.

// ReSharper disable ArrangeModifiersOrder
// ReSharper disable InconsistentNaming

//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using System.Diagnostics;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace BrowseServersWeb
{
    public partial class _Default : System.Web.UI.Page
    {
        // Use a shared client instance to allow for better optimization.
        static private readonly EasyDAClient Client = new EasyDAClient();

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ServerElementCollection serverElements = Client.BrowseServers("");
                Debug.Assert(!(serverElements.Keys is null));

                // ReSharper disable once LoopCanBePartlyConvertedToQuery
                foreach (ServerElement serverElement in serverElements)
                {
                    Debug.Assert(!(serverElement is null));
                    ListBox1.Items.Add(serverElement.ServerClass);
                }
                ListBox1.Visible = true;
            }
            catch (OpcException ex)
            {
                TextBox1.Text = ex.GetBaseException().Message;
                TextBox1.Visible = true;
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            Load += Page_Load;
        }
    }
}
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

' ReSharper disable InconsistentNaming

Partial Public Class _Default
    Inherits Page

    ' Use a shared client instance to allow for better optimization.
    Shared ReadOnly Client As New EasyDAClient

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Try
            Dim serverElements = Client.BrowseServers("")

            For Each serverElement In serverElements
                ListBox1.Items.Add(serverElement.ServerClass)
            Next
            ListBox1.Visible = True

        Catch ex As OpcException
            TextBox1.Text = ex.GetBaseException.Message
            TextBox1.Visible = True
        End Try
    End Sub

End Class

 

See Also

Conceptual